import java.util.Scanner;
import java.util.Stack;

/**
 * @author: gao
 * @create-date: 2025/4/7 16:02
 */

public class Solution {
    public boolean checkValidString(String s) {
        Stack<Integer> stack1 = new Stack<>();
        Stack<Integer> stack2 = new Stack<>();

        //遍历字符串
        for (int i = 0; i < s.length(); i++) {
            char ch = s.charAt(i);
            if (ch == '(') {
                stack1.push(i);
            } else if (ch == '*') {
                stack2.push(i);
            } else {
                if (!stack1.isEmpty()) {
                    stack1.pop();
                } else if (!stack2.isEmpty()) {
                    stack2.pop();
                } else {
                    return false;
                }
            }
            
        }

        while (!stack1.isEmpty()) {
            if (stack2.isEmpty()) {
                return false;
            }
            int index1 = stack1.pop();
            int index2 = stack2.pop();
            if (index1 > index2) {
                return false;
            }
        }
        return true;
    }

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        while (in.hasNextLine()) {
            String s = in.nextLine();
            Solution solution = new Solution();
            System.out.println(solution.checkValidString(s));
        }
    }
}